import request from "./request";

//请求商品数据
export interface PostData {
  category1Id?: string;
  category2Id?: string;
  category3Id?: string;
  categoryName?: string;
  keyword?: string;
  order?: string;
  pageNo?: number;
  pageSize?: number;
  props?: string[];
  trademark?: string;
}
export const getItem = (data: PostData) =>
  request({ method: "post", url: "/list", data });

//获取商品详情数据
export const getDetail = (id: any) =>
  request({ method: "get", url: `/item/${id}` });

//跳转购物车,(改变购物车商品数量)
interface skuMsg {
  skuID: any;
  skuNum: string;
}

export const goCart = (skuMsg: skuMsg) =>
  request({
    method: "post",
    url: `/cart/addToCart/${skuMsg.skuID}/${skuMsg.skuNum}`,
  });

//获取购物车列表
export const getCartList = () =>
  request({ method: "get", url: "/cart/cartList" });

//改变购物车商品选中状态
interface ChangeChecked {
  skuID: string;
  isChecked: string;
}
export const changeCartItemChecked = (data: ChangeChecked) =>
  request({
    method: "get",
    url: `/cart/checkCart/${data.skuID}/${data.isChecked}`,
  });


  //删除购物车商品
export const deleteCartItem = (skuId:string) => request({method:'delete',url:`/cart/deleteCart/${skuId}`})